from dataclasses import dataclass

import redis




@dataclass
class MyRedis():
    host:str = 'localhost'
    port: int = 6379
    db: int = 0
    password: str = "mykernel.cn"

    def __post_init__(self):
        self.origin = redis.Redis(host=self.host, port=self.port, db=self.db,password=self.password)
    def lpush(self,value,name='msg'):
        return self.origin.execute_command("LPUSH", name, value)
    def rpop(self,name='msg'):
        return self.origin.execute_command("RPOP", name)

if __name__ == '__main__':
    r = MyRedis()
    # r.lpush('提交任务请求api后立即返回完成，后台慢慢处理任务，完成后，前端自动展示任务结果。javascript客户端和python服务端代码怎么实现')
    r.lpush('django-redis 常用操作')
